<template>
	<view class="container">
		<!-- 导航栏 -->
		<view class="navbar">
			<view v-for="(item, index) in navItems" :key="index" class="nav-item" @click="navigateTo(index)"
				:class="{ active: currentIndex === index }">
				{{ item.text }}
			</view>
		</view>

		<!-- 滑块区域 -->
		<view class="slider-area">
			<view v-for="(item, index) in navItems" :key="index" class="slider-item"
				:class="{ active: currentIndex === index }">
				<!-- 这里可以放置与每个滑块对应的内容 -->
				<view v-if="order.status == index " v-for="(order, tindex) in orderList" :key="tindex">
					<view style="background-color: #ffffff; border-radius: 10px; margin: 5px 0; padding: 15px">

						<view v-if="index === 1 ">
							<navigator class="flex-row justify-between clearfix"
								:url="'/pages/order/to_be_paid/to_be_paid?orderNo='+order.orderNo">
								<view style="text-align: left;" class="slider-area_name">订单编号：{{order.orderNo}}</view>
								<view class="slider-area_category ">
									{{ order | statusFilter() }}
								</view>
							</navigator>
						</view>
						<view v-if="index === 2 ">
							<navigator class="flex-row justify-between clearfix"
								:url="'/pages/order/to_be_use/to_be_use?orderNo='+order.orderNo">
								<view style="text-align: left;" class="slider-area_name">订单编号：{{order.orderNo}}</view>
								<view class="slider-area_category ">
									{{ order | statusFilter() }}
								</view>
							</navigator>

						</view>
						<view v-if="index === 3 ">
							<navigator class="flex-row justify-between clearfix"
								:url="'/pages/order/to_be_evaluated/to_be_evaluated?orderNo='+order.orderNo">
								<view style="text-align: left;" class="slider-area_name">订单编号：{{order.orderNo}}</view>
								<view class="slider-area_category ">
									{{ order | statusFilter() }}
								</view>
							</navigator>
						</view>

						<view style="display: flex; justify-content: space-between; padding-top: 5px">
							<view style="padding: 5px 0px">
								<image :src="order.image" style="width: 150px; height: 100px; border-radius: 5px">
								</image>
							</view>
							<view style="display: grid; text-align: right">
								<view style="font-size: 12px; color: #686868">
									<view style="text-align: left;">服务项目：{{ order.project }}</view>
									<view style="text-align: left;">服务门店：{{ order.stores }}</view>
									<!-- <view style="text-align: left;">订单编号：{{order.orderNo}}</view> -->
									<view style="text-align: left;">下单时间：{{order.time}}</view>
								</view>
								<!-- <view></view> -->
								<view style="font-size: 18px; font-weight: bold; color: brown; color: #ff1111">
									<text style="color: #000; font-size: 16px;font-weight: normal;">实付：</text>
									<text style="font-size: 10px">￥</text>
									<text style="">{{ order.price }}元</text>
								</view>


							</view>
						</view>
						<view
							style="display: flex; justify-content: space-between; width: 100%; align-items: flex-end; padding-top: 10px">
							<view style="display: flex; font-size: 12px; color: #686868">
								<button @click="toAppraise" size="mini" class="slider-area_appraise" plain="true">{{item.appraise}}</button>
								<button @click="showModal" size="mini" class="slider-area_again">{{item.again}}</button>
							</view>
						</view>

						<!-- 模态框 -->
						<view class="modal" v-if="isModalVisible  && (index == 1 || index == 2) ">
							<view class="modal-content">
								<image class="qrcode" src="/static/qrcode.jpg" mode="aspectFit"></image>
								<button type="warn" @click="hideModal">关闭</button>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>


	</view>
</template>

<script>
	export default {
		data() {
			return {
				isModalVisible: false, //  付款码显示框
				payStatus: 0, // 支付状态
				currentIndex: 0, // 当前选中的滑块索引  
				// 索引
				navItems: [{
						text: '全部',
						appraise: '立即评价',
						again: '再来一单',
						// payStatus:
					},
					{
						text: '待支付',
						appraise: '立即取消',
						again: '立即支付'
					},
					{
						text: '待使用',
						appraise: '申请退款',
						again: '扫码结算'
					},
					{
						text: '待评价',
						appraise: '立即评价',
						again: '再来一单'
					}
				],
				// 每个项目对应的列表信息
				orderList: [{
						orderNo: 'f820391272917233',
						name: '全车保养，大保养,全车保养，大保养,全车保养，大保养,全车保养，大保养,全车保养，大保养,',
						status: 0,
						payStatus: 1,
						price: 99,
						image: 'https://img0.baidu.com/it/u=2547121781,4013571805&fm=253&fmt=auto&app=138&f=JPEG?w=1000&h=500',
						project: '车辆保养',
						stores: '大宝维修点',
						model: '奔驰FWE4',
						time: '2024-03-30 22:18:18'
					}, {
						orderNo: 'f820391272917233',
						name: '全车保养，大保养,全车保养，大保养,全车保养，大保养,全车保养，大保养,全车保养，大保养,',
						status: 0,
						payStatus: 0,
						price: 99,
						image: 'https://img0.baidu.com/it/u=2547121781,4013571805&fm=253&fmt=auto&app=138&f=JPEG?w=1000&h=500',
						project: '车辆保养',
						stores: '大宝维修点',
						model: '奔驰FWE4',
						time: '2024-03-30 22:18:18'
					},
					{
						orderNo: 'f820391272917244',
						name: '全车保养，大保养',
						status: 0,
						payStatus: 0,
						price: 99,
						image: 'https://img2.baidu.com/it/u=1748872470,3876311713&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=667',
						project: '车辆保养',
						stores: '大宝维修点',
						model: '奔驰FWE4',
						time: '2024-03-30 22:18:18'
					},
					{
						orderNo: 'f820391272917255',
						name: '全车保养，大保养',
						status: 0,
						payStatus: 0,
						price: 99,
						image: 'https://img1.baidu.com/it/u=3997934171,3549174996&fm=253&fmt=auto&app=138&f=PNG?w=500&h=606',
						project: '车辆保养',
						stores: '大宝维修点',
						model: '奔驰FWE4',
						time: '2024-03-30 22:18:18'
					},
					{
						orderNo: 'f820391272917266',
						name: '全车保养，大保养',
						status: 1,
						payStatus: 0,
						price: 99,
						image: 'https://img0.baidu.com/it/u=2547121781,4013571805&fm=253&fmt=auto&app=138&f=JPEG?w=1000&h=500',
						project: '车辆保养',
						stores: '大宝维修点',
						model: '奔驰FWE4',
						time: '2024-03-30 22:18:18'
					},
					{
						orderNo: 'f820391272917277',
						name: '插件可开通广告的功能，插件开通广告后，广告收益归插件作者所有，可点击下方“操作”栏目中的“广告配置”选项进行开通。',
						status: 1,
						payStatus: 0,
						price: 99,
						image: 'https://img2.baidu.com/it/u=2872967936,2196350074&fm=253&fmt=auto&app=138&f=JPEG?w=667&h=500',
						project: '车辆保养',
						stores: '大宝维修点',
						model: '奔驰FWE4',
						time: '2024-03-30 22:18:18'
					},
					{
						orderNo: 'f820391272917288',
						name: '全车保养，大保养',
						status: 1,
						payStatus: 0,
						price: 99,
						image: 'https://img0.baidu.com/it/u=3981502583,4230287884&fm=253&fmt=auto&app=120&f=JPEG?w=609&h=356',
						project: '车辆保养',
						stores: '大宝维修点',
						model: '奔驰FWE4',
						time: '2024-03-30 22:18:18'
					},
					{
						orderNo: 'f820391272917299',
						name: '全车保养，大保养',
						status: 1,
						payStatus: 0,
						price: 99,
						image: 'https://img2.baidu.com/it/u=2253615989,138345197&fm=253&fmt=auto&app=120&f=JPEG?w=750&h=500',
						project: '车辆保养',
						stores: '大宝维修点',
						model: '奔驰FWE4',
						time: '2024-03-30 22:18:18'
					},
					{
						orderNo: 'f820391272917200',
						name: '全车保养，大保养',
						status: 2,
						payStatus: 0,
						price: 99,
						image: 'https://img0.baidu.com/it/u=2547121781,4013571805&fm=253&fmt=auto&app=138&f=JPEG?w=1000&h=500',
						project: '车辆保养',
						stores: '大宝维修点',
						model: '奔驰FWE4',
						time: '2024-03-30 22:18:18'
					},
					{
						orderNo: 'f820391272917211',
						name: '全车保养，大保养',
						status: 1,
						payStatus: 0,
						price: 99,
						image: 'https://img2.baidu.com/it/u=1748872470,3876311713&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=667',
						project: '车辆保养',
						stores: '大宝维修点',
						model: '奔驰FWE4',
						time: '2024-03-30 22:18:18'
					},
					{
						orderNo: 'f820391272917222',
						name: '全车保养，大保养',
						status: 1,
						payStatus: 0,
						price: 99,
						image: 'https://img2.baidu.com/it/u=1748872470,3876311713&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=667',
						project: '车辆保养',
						stores: '大宝维修点',
						model: '奔驰FWE4',
						time: '2024-03-30 22:18:18'
					},
					{
						orderNo: 'f820391272917257',
						name: '全车保养，大保养',
						status: 3,
						payStatus: 0,
						price: 99,
						image: 'https://img2.baidu.com/it/u=1748872470,3876311713&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=667',
						project: '车辆保养',
						stores: '大宝维修点',
						model: '奔驰FWE4',
						time: '2024-03-30 22:18:18'
					}
				]


			};
		},
		filters: {
			statusFilter: function(item) {
				if (item.soldStatus != null && item.soldStatus == 1) {
					return '售后中';
				}
				let status = {
					0: '已完成',
					1: '未付款',
					2: '已付款',
					3: '待评价'
				};
				return status[item.status];
			}
		},
		methods: {
			navigateTo(index) {
				console.log(index);
				this.currentIndex = index;
				// 这里可以添加其他逻辑，比如根据索引加载对应的数据  
			},
			// 显示模态框  
			showModal() {
				this.isModalVisible = true
			},

			// 隐藏模态框  
			hideModal() {
				this.isModalVisible = false
			},
			toAppraise(){
				uni.navigateTo({
					url:"/pages/order/appraise/appraise"
				})
			}
			
			
		}
	};
</script>

<style scoped>
	.container {
		font-weight: 600;
		/* padding: 20px; */
	}

	.navbar {
		display: flex;
		justify-content: space-around;
		border-bottom: 1px solid #ddd;
		margin-bottom: 20px;
	}

	.nav-item {
		flex: 1;
		text-align: center;
		padding: 10px 0;
		cursor: pointer;
	}

	.nav-item.active {
		color: #4284ff;
		/* 当前选中项的颜色 */
		border-bottom: 2px solid #4284ff;
	}


	.slider-area {
		display: flex;
		flex-direction: column;
		/* 垂直排列滑块 */
	}

	.slider-item {
		margin-bottom: 10px;
		display: none;
		/* 默认隐藏所有滑块 */
	}

	.slider-item.active {
		display: block;
		/* 只显示当前选中的滑块 */
	}

	.slider-area_name {
		width: 200px;
		overflow: hidden;
		font-size: 13px;
		font-weight: 550;
		float: left;
		color: #646464
	}

	.slider-area_category {
		font-size: 10px;
		font-weight: bold;
		height: 20px;
		padding: 2px 10px;
		border-radius: 15px 15px 0px 15px;
		color: #ffffff;
		float: right;
		background: #55aaff;
	}

	.slider-area_appraise {
		border: 1px solid #55aaff;
		margin: 0 50px;
	}

	.slider-area_again {
		background-color: #55aaff;
		color: #fff;
		margin: 0 20px;
	}

	.clearfix:after,
	.clearfix:before {
		content: "";
		display: table;
	}

	.clearfix:after {
		clear: both;
	}

	.clearfix {
		/* *zoom: 1; */
	}

	.tabs {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: space-between;
		width: 100%;
	}

	.lines-2 {
		display: -webkit-box;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
		overflow: hidden;
		text-overflow: ellipsis;
		line-height: 1.2;
	}



	.modal {
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
		background-color: rgba(0, 0, 0, 0.5);
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.modal-content {
		background-color: white;
		padding: 20px;
		border-radius: 10px;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.qrcode {
		width: 150px;
		height: 150px;
		margin-bottom: 20px;
	}
</style>